<template>
    <div class="scfs">
        <div class="my-header">
            <div style="position:relative; top:10px; height:30px;width:100%">
                <div style="position: absolute; right: 10px;">
                    <a-space>
                        <a-button type="outline">保存</a-button>
                        <a-button type="outline">成品面料信息维护</a-button>
                        <a-button type="outline" @click="exCustomer">导入台巨客户</a-button>
                    </a-space>
                </div>
            </div>
            <div style="height: 24px;width: 100%;border-bottom: 1px solid #e5e7eb; margin-bottom: 15px;"></div>
            <div class="search-form" v-if="headerShow">
                <a-form ref="formRef" :model="form.a">
                    <a-row>
                        <a-col :span="6">
                            <a-form-item field="authorizedStrengthTime" label="下单日期:" label-col-flex="100px">
                                <a-date-picker  popup-container="html"  v-model="form.a.authorizedStrengthTime" style="width: 270px;" />
                            </a-form-item>
                        </a-col>
                        <a-col :span="6">
                            <a-form-item field="orderCode" label="订单号：" label-col-flex="100px">
                                <!-- <a-select popup-container="html"  :style="{ width: '320px' }" v-model="form.a.authorizedStrengthTime" allow-clear>
                            </a-select> -->
                                <!-- <a-date-picker  popup-container="html"  v-model="form.a.authorizedStrengthTime" style="width: 270px;" /> -->
                                <a-input v-model="form.a.orderCode" readonly style="width:270px" />
                            </a-form-item>
                        </a-col>
                        <a-col :span="6">
                            <a-form-item field="placeDepartment" label="下单部门:" label-col-flex="100px">
                                <a-select popup-container="html"  :style="{ width: '270px' }" v-model="form.a.placeDepartment">
                                    <a-option v-for="item of basicData.ProductionMode" :value="item.id" :key="item.id"
                                        :label="item.productionMode" />
                                </a-select>

                            </a-form-item>
                        </a-col>



                        <a-col :span="6">
                            <a-form-item field="testCriterion" label="测试标准:" label-col-flex="100px">
                                <a-select popup-container="html"  :style="{ width: '270px' }" v-model="form.a.testCriterion" allow-clear>
                                    <a-option v-for="item of basicData.VerifyStandard" :value="item.id" :key="item.id"
                                        :label="item.verifyStandard" />
                                </a-select>
                            </a-form-item>
                        </a-col>
                        <a-col :span="6">
                            <a-form-item field="lastDeliveryTime" label="交货日期:" label-col-flex="100px">
                                <a-date-picker  popup-container="html"  v-model="form.a.lastDeliveryTime" style="width: 270px;" />
                            </a-form-item>
                        </a-col>
                        <a-col :span="6">
                            <a-form-item field="clientDyeCode" label="客户染整单号：" label-col-flex="100px">
                                <a-input v-model="form.a.clientDyeCode" style="width:270px" />
                            </a-form-item>
                        </a-col>




                        <a-col :span="6">
                            <a-form-item field="coloringIlluminant" label="对色光源:" label-col-flex="100px">
                                <a-select popup-container="html"  :loading="loading" :allowClear="true" @search="coloringIlluminantSear"
                                    v-model="form.a.coloringIlluminant" :filter-option="false" allow-search
                                    style="width:270px;" :trigger-props="{ autoFitPopupMinWidth: true }"
                                    @change="selectChange" @focus="coloringIlluminantFun">
                                    <a-option v-for="item in pageDataList" :label="item.colourLight"
                                        :value="item.colourLight">{{ item.colourLight }}</a-option>
                                </a-select>
                            </a-form-item>
                        </a-col>

                        <a-col :span="6">
                            <a-form-item field="customOrderCode" label="客户订单号:" label-col-flex="100px">
                                <a-input v-model="guanxiForm.customOrderCode" style="width:270px" />
                            </a-form-item>
                        </a-col>

                        <a-col :span="6">
                            <a-form-item field="dyeAuditDate" label="总部审核时间:" label-col-flex="100px">
                                <a-date-picker  popup-container="html"  v-model="form.a.dyeAuditDate" style="width: 270px;" />
                            </a-form-item>
                        </a-col>

                        <a-col :span="6">
                            <a-form-item field="customName" label="客户名称:" label-col-flex="100px"
                                :validate-trigger="['change', 'blur']" :rules="[{ required: true, message: '客户名称必填' }]">

                                <!-- <a-select popup-container="html"  v-if="showJu" :style="{ width: '270px' }" v-model="form.a.customName">
                                    <a-option v-for="item of basicData.custom" :value="item.id" :key="item.id"
                                        :label="item.customName" />
                                </a-select>

                                <a-select popup-container="html"  v-else="showJu" :style="{ width: '270px' }" v-model="form.a.customName" disabled>
                                    <a-option v-for="item of basicData.custom" :value="item.id" :key="item.id"
                                        :label="item.customName" />
                                </a-select> -->

                                <a-select popup-container="html"  :loading="loading" :allowClear="true" @search="customNameSear"
                                    v-model="form.a.customName" :filter-option="false" allow-search style="width:270px;"
                                    :trigger-props="{ autoFitPopupMinWidth: true }" @focus="customNameFun">
                                    <a-option v-for="item in pageDataList" :label="item.customName" :value="item.customName"
                                        @click="deliveryAddressAll(item.id)">{{ item.customName }}</a-option>
                                </a-select>

                            </a-form-item>
                        </a-col>

                        <a-col :span="6">
                            <a-form-item field="orderNature" label="订单性质:" label-col-flex="100px">
                                <a-select popup-container="html"  :style="{ width: '270px' }" v-model="form.a.orderNature" allow-clear>
                                    <a-option v-for="item of basicData.orderNature" :value="item.id" :key="item.id"
                                        :label="item.detailName" />
                                </a-select>
                            </a-form-item>
                        </a-col>

                        <a-col :span="6">
                            <a-form-item field="labelFormatCode" label="标签格式:" label-col-flex="100px">
                                <!-- <a-select popup-container="html"  :style="{ width: '270px' }" v-model="form.a.labelFormatCode" allow-clear>
                                    <a-option v-for="item of basicData.labelFormat" :value="item.id" :key="item.id"
                                        :label="item.labelFormat" />
                                </a-select> -->

                                <a-select popup-container="html"  :loading="loading" :allowClear="true" @search="labelFormatCodeSear"
                                    v-model="form.a.labelFormatCode" :filter-option="false" allow-search
                                    style="width:270px;" :trigger-props="{ autoFitPopupMinWidth: true }"
                                    @change="selectChange" @focus="labelFormatCodeFun">
                                    <a-option v-for="item in pageDataList" :label="item.labelFormat"
                                        :value="item.labelFormat">{{ item.labelFormat }}</a-option>
                                </a-select>
                            </a-form-item>
                        </a-col>

                        <a-col :span="6">
                            <a-form-item field="customOrderName" label="客订名称:" label-col-flex="100px">
                                <a-input v-if="showJu" v-model="form.a.customOrderName" style="width:270px" />
                                <a-input v-else="showJu" v-model="form.a.customOrderName" readonly style="width:270px" />
                            </a-form-item>
                        </a-col>

                        <a-col :span="6">
                            <a-form-item field="repairCause" label="回修原因:" label-col-flex="100px">
                                <!-- <a-input v-model="form.a.repairCause" style="width:270px" /> -->
                                <a-select popup-container="html"  :loading="loading" :allowClear="true" @search="repairCauseSear"
                                    v-model="form.a.repairCause" :filter-option="false" allow-search style="width:270px;"
                                    :trigger-props="{ autoFitPopupMinWidth: true }" @change="selectChange"
                                    @focus="repairCauseFun">
                                    <a-option v-for="item in pageDataList" :label="item.repairCause"
                                        :value="item.repairCause">{{ item.repairCause }}</a-option>
                                </a-select>
                            </a-form-item>
                        </a-col>

                        <a-col :span="6">
                            <a-form-item field="deliveryAddress" label="送货地址:" label-col-flex="100px">
                                <a-input v-model="form.a.deliveryAddress" style="width:270px" />
                            </a-form-item>
                        </a-col>

                        <a-col :span="6">
                            <a-form-item field="ultimatelyBuyer" label="最终买家:" label-col-flex="100px">
                                <a-select popup-container="html"  :style="{ width: '270px' }" v-model="form.a.ultimatelyBuyer" allow-clear>
                                    <a-option v-for="item of basicData.custom" :value="item.id" :key="item.id"
                                        :label="item.customName" />
                                </a-select>
                            </a-form-item>
                        </a-col>

                        <a-col :span="6">
                            <a-form-item field="marketType" label="面料销售类型:" label-col-flex="100px">
                                <a-select popup-container="html"  :style="{ width: '270px' }" v-model="form.a.marketType" allow-clear>
                                    <a-option v-for="item of basicData.plusMaterial" :value="item.id" :key="item.id"
                                        :label="item.plusMaterial" />
                                </a-select>
                            </a-form-item>
                        </a-col>
                        <a-col :span="6">
                            <a-form-item field="hqCraft" label="总部工艺:" label-col-flex="100px">
                                <a-select popup-container="html"  :style="{ width: '270px' }" v-model="form.a.hqCraft" allow-clear>
                                    <a-option v-for="item of basicData.plusMaterial" :value="item.id" :key="item.id"
                                        :label="item.plusMaterial" />
                                </a-select>
                            </a-form-item>
                        </a-col>
                        <a-col :span="6">
                            <a-form-item field="pack" label="包装要求:" label-col-flex="100px">
                                <a-input v-model="form.a.pack" style="width:270px" />
                            </a-form-item>
                        </a-col>

                        <a-col :span="6">
                            <a-form-item field="marketType" label="布号备注:" label-col-flex="100px">
                                <a-input v-model="form.a.customOrderName" style="width:270px" />
                            </a-form-item>
                        </a-col>
                        <a-col :span="24">
                            <a-form-item field="marketType" label="客户要求:" label-col-flex="100px">
                                <a-textarea placeholder="Please enter something" allow-clear style="width:99%" />
                            </a-form-item>
                        </a-col>
                    </a-row>
                </a-form>
            </div>

            <div class="my-divisders">
                <a-divider orientation="center">
                    <icon-double-up v-if="headerShow" @click="headerShow = false" :strokeWidth="2" :size="18" />
                    <icon-double-down v-else @click="headerShow = true" :strokeWidth="2" :size="18" />
                </a-divider>
            </div>
        </div>

        <!-- <div style="padding:10px"></div> -->
        <div ref="tablediv" style="padding: 10px; box-sizing: border-box;min-height:100%;background-color: #fff;">
            <a-tabs   :lazy-load="true" default-active-key="2" @change="guanxi">

                <a-tab-pane key="2" title="订单明细列表">
                    <div>
                        <a-form :model="form.a">
                            <a-row>
                                <a-col :span="5">
                                    <a-form-item field="clientDyeCode" label="制单：" label-col-flex="50px">
                                        <a-input v-model="form.a.clientDyeCode" style="width:270px" />
                                    </a-form-item>
                                </a-col>
                                <a-col :span="5">
                                    <a-form-item field="clientDyeCode" label="审核：" label-col-flex="50px">
                                        <a-input v-model="form.a.clientDyeCode" style="width:270px" />
                                    </a-form-item>
                                </a-col>
                                <a-col :span="5">
                                    <el-button type="primary" :icon="Search" class="stbutencx"
                                        style="margin-left: 5px;">查询</el-button>
                                    <el-button type="success" :icon="CirclePlus" class="stbutenxz"
                                        @click="planOrderDetailsAdd">新增</el-button>
                                </a-col>

                            </a-row>
                        </a-form>
                        <!-- <el-button type="success" :icon="CirclePlus" class="stbutenxz"
                            @click="planOrderDetailsAdd">新增</el-button> -->
                    </div>
                    <div style="height:15px;"></div>

                    <AgGridVuesCopys style="height:400px" class="ag-theme-alpine" :columnDefs="tco"
                        :rowData="form.a.planOrderDetails" :defaultColDef="defaultColDef" :enableColResize="true"
                        rowSelection="multiple" @grid-ready="gridReadyeB">
                    </AgGridVuesCopys>
                </a-tab-pane>

                <a-tab-pane key="3" title="总部坯布信息">
                    <div class="my-tool-bar">
                        <a-button type="primary" @click="countBu">查询</a-button>
                    </div>
                    <div style="height:15px;"></div>
                    <!-- <a-table :columns="total" :data="form.a.planOderGreys" /> -->
                    <AgGridVuesCopys style="height:35vh;" class="ag-theme-alpine" :columnDefs="total"
                        :rowData="form.a.planOderGreys" :defaultColDef="defaultColDef" rowSelection="multiple">
                    </AgGridVuesCopys>
                </a-tab-pane>
                <a-tab-pane key="4" title="色号最新生产车间">
                    <div class="my-tool-bar">
                        <a-button type="primary" @click="colorChe">查询</a-button>
                    </div>
                    <div style="height:15px;"></div>
                    <!-- <a-table :columns="colorCar" :data="form.a.planOrderWorkshop" /> -->
                    <AgGridVuesCopys style="height:35vh;" class="ag-theme-alpine" :columnDefs="colorCar"
                        :rowData="form.a.planOrderWorkshop" :defaultColDef="defaultColDef" rowSelection="multiple">
                    </AgGridVuesCopys>
                </a-tab-pane>
                <a-tab-pane key="5" title="管型设置">
                    <div class="tjan">
                        <div class="my-tool-bar" style="margin-bottom:10px">
                            <el-button type="success" :icon="CirclePlus" class="stbutenxz"
                                @click="planorderCastAdd">新增</el-button>
                        </div>
                    </div>
                    <AgGridVuesCopys style="height:400px" class="ag-theme-alpine" :columnDefs="tcy"
                        :rowData="form.a.planOrderCast" :defaultColDef="defaultColDef" :enableColResize="true"
                        rowSelection="multiple" @grid-ready="planorderReaGr">
                    </AgGridVuesCopys>
                </a-tab-pane>

                <a-tab-pane key="1" title="客户要求">
                    <div class="my-tool-bar">
                        <el-button type="primary" :icon="CirclePlus" class="stbutencx" @click="getBu">取布种客户要求</el-button>
                    </div>
                    <div style="height:15px;"></div>
                    <!-- <a-table :columns="total" :data="form.a.planOderGreys" /> -->
                    <AgGridVuesCopys style="height:35vh;" class="ag-theme-alpine" :columnDefs="InforRequirement"
                        :rowData="form.a.requirement" :defaultColDef="defaultColDef" rowSelection="multiple">
                    </AgGridVuesCopys>
                </a-tab-pane>

                <a-tab-pane key="6" title="测试要求">
                    <div style="height:15px;"></div>
                    <!-- <a-table :columns="total" :data="form.a.planOderGreys" /> -->
                    <AgGridVuesCopys style="height:35vh;" class="ag-theme-alpine" :columnDefs="testItems"
                        :rowData="form.a.requirement" :defaultColDef="defaultColDef" rowSelection="multiple">
                    </AgGridVuesCopys>
                </a-tab-pane>

            </a-tabs>
        </div>

        <a-drawer :drawer-style="{ 'zIndex': 9999 }" placement="bottom" :mask-closable="false" width="100" height="100%"
            :visible="pageData.importAdd" unmountOnClose @ok="sideaOk" @cancel="sideaNo" cancel-text='关闭' ok-text='保存'>

            <template #title>
                <div style="position: absolute; right: 50px;">
                    <!-- <Toolbar :items="['查询 ', '确定', 'Excel资料导入', '导出']" @add="addHandler" @import="importHandler"
                        @del="deleteHandler" @select="selectHandler" @export="exports" @excel="downloadHandler">
                    </Toolbar> -->
                    <el-button plain :icon="Search" @click="guanxiCount">查询</el-button>
                    <!-- <el-button plain @click="yesOrder">确定</el-button> -->
                    <el-button plain :icon="CirclePlus" @click="downloadHandler">模板下载</el-button>
                    <el-button plain :icon="CirclePlus" @click="importHandler">导入</el-button>
                </div>

                <div class="my-tool-bar">
                    后台巨客户
                    <!-- <el-button type="primary" :icon="CirclePlus" class="stbutencx"
                        @click="importHandler">导入后台巨客户</el-button> -->
                    <!-- <el-button type="primary" :icon="CirclePlus" class="stbutencx"
                        @click="importHandler">导入后台巨客户按钮</el-button> -->
                    <!-- <el-button type="primary" :icon="CirclePlus" class="stbutencx" @click="downloadHandler">模板下载</el-button>
                    <el-button type="primary" :icon="CirclePlus" class="stbutencx" @click="yesOrder">确定</el-button> -->
                </div>
            </template>
            <div>
                <a-form :model="guanxiForm">
                    <a-row :gutter="16">
                        <a-col :span="4">
                            <a-form-item label="客户订单号:" label-col-flex="100px">
                                <a-input v-model="guanxiForm.customOrderCode" />
                            </a-form-item>
                        </a-col>
                        <a-col :span="4">
                            <a-form-item field="clothCode" label="布号:" label-col-flex="100px">
                                <!-- <el-select v-model="guanxiForm.clothCode" filterable @click="selectChange">
                                    <el-option v-for="item in optionsList" :key="item.id" :label="item.clothCode"
                                        :value="item.clothCode" />
                                </el-select> -->
                                <a-select popup-container="html"  :loading="loading" :allowClear="true" @search="clothCodeSearch"
                                    v-model="guanxiForm.clothCode" :filter-option="false" allow-search
                                    @focus="clothCodeBoSel" style="width:270px;"
                                    :trigger-props="{ autoFitPopupMinWidth: true }">
                                    <a-option v-for="item in optionsList" :label="item.clothCode" :value="item.clothCode">{{
                                        item.clothCode + '————' + item.brandName
                                    }}</a-option>
                                </a-select>


                            </a-form-item>
                        </a-col>
                        <a-col :span="4">
                            <a-form-item field="productName" label="品名:" label-col-flex="100px">
                                <!-- <el-select v-model="guanxiForm.productName" filterable @click="selectPin">
                                    <el-option v-for="item in pinList" :key="item.id" :label="item.brandName"
                                        :value="item.brandName" />
                                </el-select> -->
                                <a-select popup-container="html"  :loading="loading" :allowClear="true" @search="clothCodeSearchA"
                                    v-model="guanxiForm.productName" :filter-option="false" allow-search
                                    @focus="clothCodeBoSelA" style="width:270px;"
                                    :trigger-props="{ autoFitPopupMinWidth: true }">
                                    <a-option v-for="item in pinList" :label="item.brandName" :value="item.brandName">{{
                                        item.brandName + '————' + item.clothCode
                                    }}</a-option>
                                </a-select>

                            </a-form-item>
                        </a-col>
                        <a-col :span="4">
                            <a-form-item field="colorCode" label="色号:" label-col-flex="100px">
                                <a-input v-model="guanxiForm.colorCode" />
                            </a-form-item>
                        </a-col>
                        <a-col :span="4">
                            <a-form-item field="colorName" label="色称:" label-col-flex="100px">
                                <a-input v-model="guanxiForm.colorName" />
                            </a-form-item>
                        </a-col>
                    </a-row>
                </a-form>
            </div>
            <div style="height:15px;"></div>
            <a href="#" style="color:blue">订单明细列表</a>
            <div style="height:10px;"></div>

            <a-tabs   :lazy-load="true" default-active-key="1" @change="mobanYn">
                <a-tab-pane key="1" title="可用数据">
                    <AgGridVuesCopys style="height:72vh;" class="ag-theme-alpine" :columnDefs="hugeCustomer"
                        :rowData="orderCustomList.list" :defaultColDef="defaultColDef" rowSelection="multiple"
                        @grid-ready="gridReadyB">
                    </AgGridVuesCopys>
                </a-tab-pane>
                <a-tab-pane key="2" title="已用数据">
                    <AgGridVuesCopys style="height:72vh;" class="ag-theme-alpine" :columnDefs="hugeCustomer"
                        :rowData="orderCustomList.list" :defaultColDef="defaultColDef" rowSelection="multiple"
                        @grid-ready="gridReadyC">
                    </AgGridVuesCopys>
                </a-tab-pane>
            </a-tabs>
        </a-drawer>

    </div>
</template>

<script lang="ts">
import { post, get } from "@/api/http";
import { Search, CirclePlus, Delete, EditPen } from "@element-plus/icons-vue";
import {
    useTable,
    useRowKey,
    useTableColumn,
    usePagination,
    useRowSelection,
} from "@/hooks/table";
import tagRender from '@/components/SelectRenderer.vue'
import cheCk from '@/views/Aps/planOrderA/cheCkBoxComm/cheCk.vue'                               //快反需求
import cheCkBumpWhite from '@/views/Aps/planOrderA/cheCkBoxComm/cheCkBumpWhite.vue'             //撞白
import CheCkdialPrinting from '@/views/Aps/planOrderA/cheCkBoxComm/CheCkdialPrinting.vue'       //拔印
import checheCkEdgeCK from '@/views/Aps/planOrderA/cheCkBoxComm/cheCkEdge.vue'                  //珠地边
import cheCkFirstRate from '@/views/Aps/planOrderA/cheCkBoxComm/cheCkFirstRate.vue'             //一等品
import cheCKneedEnterPot from '@/views/Aps/planOrderA/cheCkBoxComm/cheCKneedEnterPot.vue'       //需进缸
import cheCkrcInfo from '@/views/Aps/planOrderA/cheCkBoxComm/cheCkrcInfo.vue'                   // 白色RC处理
import cheCkrepeatPack from '@/views/Aps/planOrderA/cheCkBoxComm/cheCkrepeatPack.vue'           //重打包
import cheCkstainResistance from '@/views/Aps/planOrderA/cheCkBoxComm/cheCkstainResistance.vue'//白色防沾处理
import cheCktakeDyeFee from '@/views/Aps/planOrderA/cheCkBoxComm/cheCktakeDyeFee.vue'           //收取染费
import cheCkwetRubbing from '@/views/Aps/planOrderA/cheCkBoxComm/cheCkwetRubbing.vue'           //问擦提升

import selectGreyCode from '@/views/Aps/planOrderA/selectList/selectGreyCode.vue'           //问擦提升
import selectGreyName from '@/views/Aps/planOrderA/selectList/selectGreyName.vue'           //问擦提升
import selectColorCode from '@/views/Aps/planOrderA/selectList/selectColorCode.vue'         //色号
import selectColorName from '@/views/Aps/planOrderA/selectList/selectColorName.vue'         //色称
import selectAffirmColor from '@/views/Aps/planOrderA/selectList/selectAffirmColor.vue'
import selectGreyType from '@/views/Aps/planOrderA/selectList/selectGreyType.vue'
import selectTrimCharges from '@/views/Aps/planOrderA/selectList/selectTrimCharges.vue'
import selectDyeingType from '@/views/Aps/planOrderA/selectList/selectDyeingType.vue'
import selectColorDepth from '@/views/Aps/planOrderA/selectList/selectColorDepth.vue'


import { ref, reactive, onMounted, onActivated, onUnmounted, watch } from "vue";
import Toolbar from "@/components/Toolbar.vue";
import { Form, Message, Modal, Pagination } from "@arco-design/web-vue";
import { FormInstance } from "@arco-design/web-vue/es/form";
import emitter from "@/hooks/useEventBus";
import validate from "@/hooks/useValidate";
//import { baseURL } from '../../../api/axios.config'
import axios from "axios";
import filedownload from 'js-file-download'
import "ag-grid-community/styles/ag-grid.css";
import "ag-grid-community/styles/ag-theme-alpine.css";
import {  } from "ag-grid-vue3";
//import aag from "./AGbut"
//import aag from "./agbuut.vue"
interface ClothSet {
    id?: any;
    serialNumber?: number | undefined,
    mercery?: string | undefined;
    deleteState?: any
    remark?: string | undefined;
    productionMode?: string | undefined;
    createName?: string | undefined;
    createTime?: string | undefined;
    updateName?: string | undefined;
    updateTime?: string | undefined;
}
interface pagings {
    size: number | string,
    total: number | string,
}
export default {
    name: "productionMode",
    setup() {
        const headerShow = ref<boolean>(true)
        const pageData = reactive<{
            clothList: ClothSet[]
            showAdd: boolean
            sideTitle: string
            dropDownData: any
            pageLoading: boolean,
            theight: number,
            tablediv: any,
            rHeight: number | undefined,
            importAdd: boolean
        }>({
            clothList: [],
            showAdd: false,
            sideTitle: "计划订单",
            dropDownData: "",
            pageLoading: false,
            theight: 0,
            tablediv: null,
            rHeight: 0,
            importAdd: false
        });
        const showJu = ref<boolean>(true)

        const form = reactive(
            {
                a: {
                    authorizedStrengthTime: '',   //下单日期
                    orderCode: '',                //订单号
                    placeDepartment: '',          //下单部门
                    testCriterion: '',            //测试标准

                    lastDeliveryTime: '',        //交货日期
                    clientDyeCode: '',           //客户染整单号
                    coloringIlluminant: '',      //对色光源
                    customOrderCode: '',         //客户订单号

                    dyeAuditDate: '',            //总部审核时间
                    customName: '',              //客户名称
                    orderNature: '',             //订单性质
                    labelFormatCode: '',         //标签格式

                    customOrderName: '',         //客订名称
                    repairCause: '',             //回修原因
                    deliveryAddress: '',         //送货地址
                    ultimatelyBuyer: '',         //最终买家

                    marketType: '',              //面料销售类型
                    hqCraft: '',                 //总部工艺
                    pack: '',                    //包装要求
                    remark: '',                  //布号备注

                    planOrderDetails: [],
                    requirement: [{
                        requiredItems: "0",
                        nowRequirement: "",
                        defaultRequirement: "",
                        unit: "",
                        greyType: "",
                        remark: "",
                    }],
                    planOderGreys: [

                    ],
                    planOrderWorkshop: [
                    ],
                    planOrderCast: []


                }
            }
        );
        const exCustomer = () => {
            pageData.showAdd = false
            pageData.importAdd = true
        }
        //新增下拉
        const basicData = reactive({
            dictTypeList: ['订单性质', '结算方式', '面料销售类型', '结算公司'],
            ProductionMode: [],
            machinType: [],
            ExchangecalorieClassify: [],
            saleType: [],
            labelFormat: [],
            UrgentCategory: [],

            orderNature: [],
            Calculation: [],
            plusMaterial: [],
            corporation: [],
            custom: [],
            hrEmployee: [],
            baCompany: [],
            VerifyStandard: [],
            coloringMatch: [],
            seasonSet: []

        })

        /*****************************************************************页签切换功能***************************************************** */
        let guanxiData = {
            houseNum: 0,
            finishedWeight: 0,
            castDyeWeight: 0
        }
        function count() {
            let a = 0;
            let b = 0;
            let c = 0;
            for (var i = 0; i < form.a.planOrderDetails.length; i++) {
                a = a + Number(form.a.planOrderDetails[i].houseNum)
                b = b + Number(form.a.planOrderDetails[i].finishedWeight)
                c = c + Number(form.a.planOrderDetails[i].castDyeWeight)
            }
            var topRows = [
                { headerName: '合计', houseNum: a, finishedWeight: b, castDyeWeight: c }
            ];
            guanxiData = {
                houseNum: Number(a),
                finishedWeight: Number(b),
                castDyeWeight: Number(c)
            }
            // gridOptionyB.value.setPinnedBottomRowData(topRows);
        }
        const guanxi = (key: any) => {
            if (key == 2) {
                count()
            }
            if (key == 5) {
                count()
                if (pageData.sideTitle === '计划订单') {
                    post({
                        url: "/aps/planOrder/getData",
                        data: guanxiData
                    }).then(({ data, code }: any) => {
                        if (code === 200) {
                            form.a.planOrderCast = data
                            console.log('aaaaaaaaaaaaaaaaaaaaaaaaaa')

                        }
                    }).catch(console.log).finally(() => {
                        pageData.pageLoading = false
                    });
                }

            }

        }

        let planOrderDetails = {
            id: null,
            needState: 0,
            clothCode: "",
            productName: "",
            colorCode: "",
            colorName: "",
            affirmColor: "",
            greyCode: "",
            greyName: "",
            houseNum: 0,
            finishedWeight: 0,
            castDyeWeight: 0,
            castDyeLength: 0,
            finishedLength: 0,
            contrastColor: "",
            edge: 0,
            bumpWhite: 0,
            firstRate: 0,
            dialPrinting: 0,
            resistanceYellow: "",
            chlorineResistant: "",
            wetRubbing: 0,
            rcInfo: 0,
            stainResistance: 0,
            dyeingType: "",
            greyType: "",
            craftCode: "",
            colorDepth: "",
            trimCharges: "",
            needEnterPot: 0,
            joinDyeType: "要求合染不收费",
            takeDyeFee: 0,
            repeatPack: 0,
            byPieceBreadth: 0,
            byPieceGramWeight: 0,
            dyeUnitPrice: 0,
            hqUnitPrice: 0,
            veryPrice: 0,
            polybagPrice: 0,
            tubePrice: 0,
            taxRate: "",
            feeConstitute: "",
            neatEmbryoTime: "",
            deliveryTime: "",
            ingredient: "",
            yarnCount: "",
            embryoOrderNumber: "",
            customClothCode: "",
            customProductName: "",
            customColorCode: "",
            customColorName: "",
            efficacious: "",
            gramWeight: 0,
            upperLimit: "",
            lowerLimit: "",
            gramUpperLimit: 0,
            gramLowerLimit: 0,
            numberCylinders: 0,
            styleNumber: "",
            tradeName: "",
            finishedClothCode: "",
            finishedClothName: "",
            needPersonnel: "",
            needTime: "",
            hqCardNumber: "",
            rawColorCode: "",
            rawColorName: "",
            currency: "",
            closeAccountWeight: 0,
            closeAccountUnit: "",
            makeEditionCost: 0
        }

        //订单明细新增
        const planOrderDetailsAdd = () => {
            form.a.planOrderDetails.push(JSON.parse(JSON.stringify(planOrderDetails)))
            setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
        }
        /***************************************************************订单明细列表*****************************************************************************/
        const defaultColDef = {
            sortable: true,
            filter: true,
            //  flex: 1,
            resizable: true,
        };
        const columnsOrder = [
            {
                headerName: "快反需求状态",
                field: "needState",

            },
            { headerName: "布号", field: "clothCode", },
            { headerName: "品名", field: "productName" },

            {
                headerName: "色号", field: "colorCode",
            },
            { headerName: "色称", field: "colorName" },
            { headerName: "确认色", field: "affirmColor", },

            {
                headerName: "坯布编号", field: "greyCode",
            },


            { headerName: "坯布名称", field: "greyName", },
            { headerName: "匹数", field: "houseNum", editable: true, },

            { headerName: "成品重量", field: "finishedWeight", editable: true, },
            { headerName: "投染重量", field: "castDyeWeight", editable: true, },
            { headerName: "投染长度", field: "castDyeLength", editable: true, },

            { headerName: "成品长度", field: "finishedLength", editable: true, },
            {
                headerName: "对色资料",
                field: "contrastColor",
                cellEditor: "agSelectCellEditor",
                editable: true,
                cellEditorParams: { values: [1, 2] }
            },
            { headerName: "珠地边", field: "edge" },

            { headerName: "撞白", field: "bumpWhite", },
            { headerName: "一等品", field: "firstRate", },
            { headerName: "拔印", field: "dialPrinting" },

            { headerName: "抗黄处理", field: "resistanceYellow", editable: true, },
            { headerName: "耐氢提升", field: "chlorineResistant", editable: true, },
            { headerName: "温擦提升", field: "wetRubbing" },

            { headerName: "白色RC处理", field: "rcInfo", },
            { headerName: "白色防粘处理", field: "stainResistance", },
            {
                headerName: "染色类型",
                field: "dyeingType",
            },

            {
                headerName: "布种类别",
                field: "greyType",
            },
            {
                headerName: "工艺代码",
                field: "craftCode",
                editable: true,
                cellEditor: "agSelectCellEditor",
                cellEditorParams: { values: [1, 2] }
            },
            {
                headerName: "颜色深浅",
                field: "colorDepth",
            },

            {
                headerName: "整理收费项目",
                field: "trimCharges",
            },
            { headerName: "需进缸", field: "needEnterPot" },
            { headerName: "合染类型", field: "joinDyeType" },

            { headerName: "收取染费", field: "takeDyeFee", },
            { headerName: "重打包", field: "repeatPack", },
            { headerName: "计件克重", field: "byPieceBreadth" },

            { headerName: "染色单价", field: "dyeUnitPrice", },
            { headerName: "总部染色单价", field: "hqUnitPrice", editable: true, },
            { headerName: "特整单价", field: "veryPrice", editable: true, },

            { headerName: "胶袋单价", field: "polybagPrice", editable: true, },
            { headerName: "纸管单价", field: "tubePrice", editable: true, },
            { headerName: "税率", field: "taxRate", editable: true, },

            {
                headerName: "费用构成",
                field: "feeConstitute",
            },
            { headerName: "齐坯日期", field: "neatEmbryoTime", },
            { headerName: "交货日期", field: "deliveryTime" },

            { headerName: "成分", field: "ingredient" },
            { headerName: "纱支", field: "yarnCount", },
            { headerName: "备坯订单号", field: "embryoOrderNumber" },

            { headerName: "客户布号", field: "customClothCode", editable: true, },
            { headerName: "客户品名", field: "customProductName", editable: true, },
            { headerName: "客户色号", field: "customColorCode", editable: true, },

            { headerName: "客户色称", field: "customColorName", editable: true, },
            { headerName: "有效门幅（CM）", field: "efficacious", },
            { headerName: "克重（M2）", field: "gramWeight", },

            { headerName: "门幅上限", field: "upperLimit", editable: true, },
            { headerName: "门幅下限", field: "lowerLimit", editable: true, },
            { headerName: "克重上限", field: "gramUpperLimit", editable: true, },

            { headerName: "克重下限", field: "gramLowerLimit", editable: true, },
            { headerName: "开卡缸数", field: "numberCylinders", },
            { headerName: "款号", field: "styleNumber" },

            // {
            //     headerName: "快反需求人员",
            //     field: "needPersonnel",
            // },
            { headerName: "快反需求日期", field: "needTime", editable: true, },

            { headerName: "总部色卡号", field: "hqCardNumber", },
            { headerName: "原色号", field: "rawColorCode", },
            { headerName: "原色称", field: "rawColorName", },

            { headerName: "币种", field: "currency" },
            { headerName: "结算重量", field: "closeAccountWeight", },
            { headerName: "结算单位", field: "closeAccountUnit" },
            { headerName: "制版费", field: "makeEditionCost" },

            { headerName: "操作", },
        ];

        const gridOptionyB = ref()
        const gridReadyeB = (params: any,) => {
            gridOptionyB.value = params.api
            console.log("触发");
        }
        let tco: any[] = columnsOrder.map((o) => {
            //let obj = {}
            if (o.headerName === '操作') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "right"
                o["width"] = 70
                o['cellRenderer'] = {
                    template: `<el-button style="color:red;"  link  @click="s">删除</el-button>`,
                    setup(props: any) {
                        const s = () => {
                            // deleteBzyq(props.params.rowIndex)
                            form.a.planOrderDetails.splice(props.params.rowIndexdex, 1)
                            setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                        }
                        return {
                            s
                        }
                    }

                }
            }
            if (o.headerName == '快反需求状态') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 150
                o['cellRenderer'] = cheCk
                o['cellRendererParams'] = {
                    color: (params: any,) => {
                        form.a.planOrderDetails[params.rowIndex].needState = params.data.needState
                        if (form.a.planOrderDetails[params.rowIndex].needState == 0) {
                            columnsOrder.delete({ headerName: "快反需求人员", field: "needPersonnel" })
                            scrollbar.value = true
                        }
                        if (form.a.planOrderDetails[params.rowIndex].needState == 1) {
                            if (scrollbar.value == true) {
                                columnsOrder.push({ headerName: "快反需求人员", field: "needPersonnel" })
                                scrollbar.value = false
                            }

                        }
                        console.log(columnsOrder)
                    }
                }
            }
            if (o.headerName == '布号') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 300
                o['cellRenderer'] = tagRender
                o['cellRendererParams'] = {
                    color: (params: any, data: any,) => {
                        // form.a.planOrderDetails[data.node.childInde].clothCode = data.data.clothCode

                        Object.keys(form.a.planOrderDetails[params.rowIndex]).forEach((key) => {
                            Object.keys(data[0]).forEach((keyP) => {
                                if (key == keyP) {
                                    form.a.planOrderDetails[params.rowIndex][key] = data[0][key]
                                }
                            })
                        })
                        setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                    }
                }
            }
            if (o.headerName == '坯布编号') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 300
                o['cellRenderer'] = selectGreyCode
                o['cellRendererParams'] = {
                    color: (params: any) => {
                        form.a.planOrderDetails[params.rowIndex].greyCode = params.data.greyCode
                        setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                    }
                }
            }
            if (o.headerName == '坯布名称') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 300
                o['cellRenderer'] = selectGreyName
                o['cellRendererParams'] = {
                    color: (params: any) => {
                        form.a.planOrderDetails[params.rowIndex].greyName = params.data.greyName
                        setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                    }
                }
            }
            if (o.headerName == '色号') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 300
                o['cellRenderer'] = selectColorCode
                o['cellRendererParams'] = {
                    color: (params: any) => {
                        form.a.planOrderDetails[params.rowIndex].colorCode = params.data.colorCode
                        setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                    }
                }
            }
            if (o.headerName == '色称') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 300
                o['cellRenderer'] = selectColorName
                o['cellRendererParams'] = {
                    color: (params: any) => {
                        form.a.planOrderDetails[params.rowIndex].colorName = params.data.colorName
                        setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                    }
                }
            }
            if (o.headerName == '确认色') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 300
                o['cellRenderer'] = selectAffirmColor
                o['cellRendererParams'] = {
                    color: (params: any) => {
                        form.a.planOrderDetails[params.rowIndex].affirmColor = params.data.affirmColor
                        setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                    }
                }
            }
            if (o.headerName == '染色类型') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 300
                o['cellRenderer'] = selectDyeingType
                o['cellRendererParams'] = {
                    color: (params: any) => {
                        form.a.planOrderDetails[params.rowIndex].dyeingType = params.data.dyeingType
                        setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                    }
                }
            }
            if (o.headerName == '布种类别') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 300
                o['cellRenderer'] = selectGreyType
                o['cellRendererParams'] = {
                    color: (params: any) => {
                        form.a.planOrderDetails[params.rowIndex].greyType = params.data.greyType
                        setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                    }
                }
            }
            if (o.headerName == '整理收费项目') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 300
                o['cellRenderer'] = selectTrimCharges
                o['cellRendererParams'] = {
                    color: (params: any) => {
                        form.a.planOrderDetails[params.rowIndex].trimCharges = params.data.trimCharges
                        setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                    }
                }
            }
            if (o.headerName == '费用构成') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 300
                o['cellRenderer'] = selectTrimCharges
                o['cellRendererParams'] = {
                    color: (params: any) => {
                        form.a.planOrderDetails[params.rowIndex].feeConstitute = params.data.feeConstitute
                        setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                    }
                }
            }
            if (o.headerName == '颜色深浅') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 300
                o['cellRenderer'] = selectColorDepth
                o['cellRendererParams'] = {
                    color: (params: any) => {
                        form.a.planOrderDetails[params.rowIndex].colorDepth = params.data.colorDepth
                        setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                    }
                }
            }
            if (o.headerName == '珠地边') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 150
                o['cellRenderer'] = checheCkEdgeCK
                o['cellRendererParams'] = {
                    color: (params: any,) => {
                        form.a.planOrderDetails[params.rowIndex].edge = params.data.edge
                    }
                }
            }
            if (o.headerName == '撞白') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 150
                o['cellRenderer'] = cheCkBumpWhite
                o['cellRendererParams'] = {
                    color: (params: any,) => {
                        form.a.planOrderDetails[params.rowIndex].bumpWhite = params.data.bumpWhite

                    }
                }
            }
            if (o.headerName == '一等品') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 150
                o['cellRenderer'] = cheCkFirstRate
                o['cellRendererParams'] = {
                    color: (params: any,) => {
                        form.a.planOrderDetails[params.rowIndex].cheCkFirstRate = params.data.cheCkFirstRate
                    }
                }
            }
            if (o.headerName == '拔印') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 150
                o['cellRenderer'] = CheCkdialPrinting
                o['cellRendererParams'] = {
                    color: (params: any,) => {
                        form.a.planOrderDetails[params.rowIndex].dialPrinting = params.data.dialPrinting
                    }
                }
            }
            if (o.headerName == '温擦提升') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 150
                o['cellRenderer'] = cheCkwetRubbing
                o['cellRendererParams'] = {
                    color: (params: any,) => {
                        form.a.planOrderDetails[params.rowIndex].wetRubbing = params.data.wetRubbing

                    }
                }
            }
            if (o.headerName == '白色RC处理') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 150
                o['cellRenderer'] = cheCkrcInfo
                o['cellRendererParams'] = {
                    color: (params: any,) => {
                        form.a.planOrderDetails[params.rowIndex].rcInfo = params.data.rcInfo

                    }
                }
            }
            if (o.headerName == '白色防粘处理') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 150
                o['cellRenderer'] = cheCkstainResistance
                o['cellRendererParams'] = {
                    color: (params: any,) => {
                        form.a.planOrderDetails[params.rowIndex].stainResistance = params.data.stainResistance

                    }
                }
            }
            if (o.headerName == '需进缸') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 150
                o['cellRenderer'] = cheCKneedEnterPot
                o['cellRendererParams'] = {
                    color: (params: any,) => {
                        form.a.planOrderDetails[params.rowIndex].needEnterPot = params.data.needEnterPot
                    }
                }
            }
            if (o.headerName == '收取染费') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 150
                o['cellRenderer'] = cheCktakeDyeFee
                o['cellRendererParams'] = {
                    color: (params: any,) => {
                        form.a.planOrderDetails[params.rowIndex].takeDyeFee = params.data.takeDyeFee

                    }
                }
            }
            if (o.headerName == '重打包') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 150
                o['cellRenderer'] = cheCkrepeatPack
                o['cellRendererParams'] = {
                    color: (params: any,) => {
                        form.a.planOrderDetails[params.rowIndex].repeatPack = params.data.repeatPack
                    }
                }
            }

            // if (o.headerName == '重打包') {
            //     o['resizable'] = false
            //     o['filter'] = false
            //     o['sortable'] = false
            //     o["pinned"] = "light"
            //     o["width"] = 150
            //     o['cellRenderer'] = {
            //         template: `<div>
            //             <a-checkbox @click="s"></a-checkbox>
            //                   </div>`,
            //         setup(props: any) {
            //             const s = () => {
            //                 form.a.planOrderDetails[props.params.rowIndex].repeatPack = form.a.planOrderDetails[props.params.rowIndex].repeatPack == 0 ? 1 : 0
            //             }
            //             return {
            //                 s
            //             }
            //         }

            //     }
            // }

            return o
        })

        /*********************************************************总坯布信息*********************************************************/
        const total = [
            {
                headerName: '',//选择列头部显示的文字，可以为空
                checkboxSelection: true,//设置为ture显示为复选框
                headerCheckboxSelection: true, //表头是否也显示复选框，全选反选用
                pinned: 'left', //固定再左边
                width: 50 //列的宽度
            },
            { headerName: "坯布编号", field: "greyCode", },
            { headerName: "坯布名称", field: "greyName" },
            { headerName: "纱批", field: "yarnHouseNum" },
            { headerName: "匹数", field: "houseNum", },
            { headerName: "重量", field: "weight" },
            { headerName: "米数", field: "lenghtNum" },
            { headerName: "布号", field: "clothCode", },
            { headerName: "品名", field: "productName" },
            { headerName: "色号", field: "colorCode" },
            { headerName: "色称", field: "colorName", },
            { headerName: "门幅", field: "larghezza" },
        ];
        //总坯布查询
        const countBu = () => {
            post({
                url: "/aps/planOrderGrey/getList",
                data: {
                    planOrderId: 1,
                }
            }).then(({ data, code }: any) => {
                if (code === 200) {
                    form.a.planOderGreys = data
                    // console.log(form.a.orderCode, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
                }
            }).catch(console.log).finally(() => {
                pageData.pageLoading = false
            });
        }
        /*******************************************************色号生产车间************************************************************ */
        const colorCar = [
            {
                headerName: '',//选择列头部显示的文字，可以为空
                checkboxSelection: true,//设置为ture显示为复选框
                headerCheckboxSelection: true, //表头是否也显示复选框，全选反选用
                pinned: 'left', //固定再左边
                width: 50 //列的宽度
            },
            { headerName: "订单号", field: "planOrderCode", },
            { headerName: "布号", field: "clothCode" },
            { headerName: "品名", field: "productName" },
            { headerName: "色号", field: "colorCode", },
            { headerName: "色称", field: "colorName" },
            { headerName: "流转卡号", field: "flowCardCode" },


            { headerName: "等待工序", field: "waitProcess", },
            { headerName: "开卡日期", field: "createOrderDate" },
            { headerName: "生产车间", field: "workshop" },
            { headerName: "匹数", field: "houseNum", },
            { headerName: "制单人", field: "createOrde" },
            { headerName: "备注", field: "remark" },


        ];
        //色号生产车间
        const colorChe = () => {
            post({
                url: "/aps/planOrder/getWorkshopInfo",
                data: {
                    colorCode: '测试01',
                }
            }).then(({ data, code }: any) => {
                if (code === 200) {
                    form.a.planOrderWorkshop = data
                    // console.log(form.a.orderCode, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
                }
            }).catch(console.log).finally(() => {
                pageData.pageLoading = false
            });
        }
        /********************************************************管型设置********************************************************************** */
        function xuHaoFun(params) {
            params.node.rowIndex = params.node.rowIndex + 1
            return params.node ? params.node.rowIndex : null
        }
        const InformationEnglishbt = [
            {
                headerName: "序号", width: 100,
                cellRenderer: xuHaoFun

            },
            {
                headerName: "管型", field: "castNum",
                editable: true,
                cellEditor: "agSelectCellEditor",
                cellEditorParams: { values: [6, 5, 4, 3, 2, 1] }
            },
            { headerName: "缸数", field: "retainingNum" },
            { headerName: "操作", },
        ];
        let tcy: any[] = InformationEnglishbt.map((o) => {
            //let obj = {}
            if (o.headerName === '操作') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "right"
                o["width"] = 70
                o['cellRenderer'] = {
                    template: `<el-button style="color:red;"  link  @click="s">删除</el-button>`,
                    setup(props: any) {
                        const s = () => {
                            form.a.planOrderCast.splice(props.params.rowIndexdex, 1)
                            setTimeout(function () { planorderCastGr.value.setRowData(form.a.planOrderCast); }, 0)
                        }
                        return {
                            s
                        }
                    }

                }
            }
            return o
        })
        const planorderCastGr = ref()
        const planorderReaGr = (params: any,) => {
            planorderCastGr.value = params.api
            console.log("触发");
        }
        //管型新增
        const planorderCastAdd = () => {
            let planOrderCast = {
                id: null,
                workshop: '',
                castNum: 1,
                retainingNum: 1,
                remark: 1
            }
            form.a.planOrderCast.push(JSON.parse(JSON.stringify(planOrderCast)))
            setTimeout(function () { planorderCastGr.value.setRowData(form.a.planOrderCast); }, 0)
        }


        /*******************************************************布种************************************************************ */
        //取布种要求
        function getBu() {
            post({
                url: "/pdm/RequireClassify/getSon",
                data: {

                },
            }).then((re: any) => {
                form.a.requirement = re
            }).catch(console.log).finally(() => {
                pageData.pageLoading = false
            });
        }

        /*******************************************************客户要求******************************************************************** */
        //客户要求
        const InforRequirement = [
            { headerName: "要求项目", field: "requiredItems", },
            { headerName: "本次要求", field: "nowRequirement", },
            { headerName: "默认要求", field: "defaultRequirement" },
            { headerName: "布种", field: "greyType" },
            { headerName: "单位", field: "unit" },
            { headerName: "备注", field: "remark" },

        ];
        /********************************************************测试项目****************************************************************************** */
        const testItems = [
            { headerName: "扭度", field: "requiredItems", },
            { headerName: "纬斜", field: "nowRequirement", },
            { headerName: "干擦", field: "defaultRequirement" },
            { headerName: "湿擦", field: "greyType" },
            { headerName: "洗水牢度", field: "unit" },
            { headerName: "汗渍牢度", field: "remark" },

            { headerName: "光汗复合", field: "requiredItems", },
            { headerName: "日晒牢度", field: "nowRequirement", },
            { headerName: "PH值", field: "defaultRequirement" },
            { headerName: "甲醛", field: "greyType" },
            { headerName: "爆破", field: "unit" },
            { headerName: "顶破", field: "remark" },
            { headerName: "抗起球", field: "remark" },

        ];

        /****************************************************************巨客户**********************************************************************/
        let yesOrderList: any = []
        const gridOptionB = ref()
        const gridReadyB = (params: any) => {
            gridOptionB.value = params.api
        }

        const orderCustomList = reactive({
            list: []
        })
        const trigger = ref('1');
        //保存接口
        const baocun = (data: any) => {
            post({
                url: "/aps/orderCustom/confirm",
                data: data
            }).then(({ data, code, message }: any) => {
                // console.log(data,"下拉返回");
                if (code === 200) {
                    Message.success({
                        content: "保存成功",
                        duration: 200,
                    });

                } else {
                    Message.error({
                        content: message,
                        duration: 5000,
                    });
                }
            });
        }
        const yesOrder = () => {
            yesOrderList = gridOptionB.value.getSelectedRows()
            if (trigger.value == '1') {
                gridOptionB.value.getSelectedRows().map((item) => {
                    // return item.customOrderCode
                    return orderCustomList.list.map((se, index) => {
                        if (se.id === item.id) {
                            orderCustomList.list.splice(index, 1)
                            setTimeout(function () { gridOptionB.value.setRowData(orderCustomList.list); }, 0)
                        }
                    })
                })
            } else {
                gridOptionB.value.getSelectedRows().map((item) => {
                    return item.customOrderCode
                })
            }

            console.log(yesOrderList, 'ss')
            baocun(yesOrderList)

        }

        //导入巨客户订单
        const sideaOk = () => {
            yesOrder()
            if (yesOrderList.length > 0) {
                form.a.customOrderCode = yesOrderList[0].customOrderCode
                form.a.customPoCode = yesOrderList[0].customPoCode
                form.a.authorizedStrengthTime = new Date(yesOrderList[0].authorizedStrengthTime)
                form.a.customName = yesOrderList[0].customName
                form.a.customOrderName = yesOrderList[0].customOrderName
                form.a.clientDocumentary = yesOrderList[0].clientDocumentary
                form.a.season = yesOrderList[0].season
                form.a.lastDeliveryTime = new Date(yesOrderList[0].lastDeliveryTime)
                form.a.initialDeliveryTime = new Date(yesOrderList[0].initialDeliveryTime)


                for (let i = 0; i < yesOrderList.length; i++) {
                    let a = { ...planOrderDetails, ...yesOrderList[i] }
                    form.a.planOrderDetails.push(JSON.parse(JSON.stringify(a)))
                    setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                }
                form.a.colourSum = form.a.planOrderDetails.length
                showJu.value = false
            }
            pageData.importAdd = false
            pageData.showAdd = true;
            count()
        }

        const sideaNo = () => {
            for (let i = 0; i < yesOrderList.length; i++) {
                let a = { ...planOrderDetails, ...yesOrderList[i] }
                form.a.planOrderDetails.push(JSON.parse(JSON.stringify(a)))
                setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
            }
            pageData.importAdd = false
            pageData.showAdd = true;
            count()
        }
        let guanxiForm = reactive({
            customOrderCode: '',
            clothCode: '',
            productName: '',
            colorCode: '',
            colorName: '',
            auditState: 0
        }
        )
        //查询
        const guanxiCount = () => {
            post({
                url: "/aps/orderCustom/getList",
                data: guanxiForm
            }).then(({ data, code }: any) => {
                // console.log(data,"下拉返回");
                console.log(data)
                if (code === 200) {
                    orderCustomList.list = data;
                }
            });
        }

        //模板下载
        const downloadHandler = () => {
            axios.get('/api/aps/orderCustom/uploadOrderCustomeModel', {
                responseType: 'blob',
                headers: {
                    token: sessionStorage.getItem('USER-TOKEN-KEY')
                }
            }).then((res) => {
                if (res.status === 200) {
                    filedownload(res.data, '巨客户模板.xlsx')
                }
            })
        }
        //导入
        const importHandler = () => {
            const inputEle: HTMLInputElement = document.createElement('input')
            inputEle.type = 'file'
            inputEle.id = 'fileUploadExcel'
            inputEle.accept = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel'
            inputEle.addEventListener('change', (e) => {
                const formData = new FormData()
                if (inputEle.files !== null) {
                    formData.append('file', inputEle.files[0] || '')
                    formData.append('customOrderCode', form.a.customOrderCode)
                } else {
                    Message.warning('未选择文件！');
                    return
                }
                pageData.pageLoading = true
                axios.post('/api/aps/orderCustom/analyseOrderCustomeModel',
                    formData,
                    {
                        headers: {
                            "Content-Type": 'multipart/form-data',
                            "token": sessionStorage.getItem('USER-TOKEN-KEY')
                        },
                    }).then((result) => {
                        if (result.data['code'] === 200) {
                            for (let i = 0; i < result.data['data'].length; i++) {
                                result.data['data'][i].id = null
                            }
                            orderCustomList.list = result.data['data']
                            Message.success('导入成功')
                        } else {
                            Message.error(result.data.message)
                        }

                    }).finally(() => {
                        // pageData.pageLoading = false
                        // doRefresh()
                        post({
                            url: "/aps/orderCustom/getList",
                        }).then(({ data, code }: any) => {
                            if (code === 200) {
                                // orderCustomList.list = data
                            }
                        }).catch(console.log).finally(() => {
                            pageData.pageLoading = false
                        });
                    })
            })
            inputEle.click()
        }

        //巨客户页签函数
        const mobanYn = (key: any) => {
            if (key == 1) {
                guanxiForm.auditState = 0
                guanxiCount()
            } else {
                guanxiForm.auditState = 1
                guanxiCount()
            }
            console.log(guanxiForm.auditState, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
        }
        /***********************************************************巨客户列表**********************************************************/
        const hugeCustomer = [
            {
                headerName: '',//选择列头部显示的文字，可以为空
                checkboxSelection: true,//设置为ture显示为复选框
                headerCheckboxSelection: true, //表头是否也显示复选框，全选反选用
                pinned: 'left', //固定再左边
                width: 50 //列的宽度
            },
            { headerName: "客户订单号", field: "customOrderCode", },
            { headerName: "卖家名称", field: "buyerName" },
            { headerName: "客户名称", field: "customOrderName" },
            { headerName: "客户跟单", field: "clientDocumentary", },
            { headerName: "下单日期", field: "authorizedStrengthTime" },
            { headerName: "交货日期", field: "deliveryTime" },
            { headerName: "季节", field: "season", },
            { headerName: "款号", field: "styleNumber" },
            { headerName: "布号", field: "colorCode" },
            { headerName: "品名", field: "productName", },
            { headerName: "系统品名", field: "systemProductName", },
            { headerName: "门幅", field: "larghezza" },
            { headerName: "克重", field: "gWeight" },
            { headerName: "颜色代码", field: "colorNum" },
            { headerName: "色号", field: "colorCode" },
            { headerName: "色称", field: "colorName" },
            { headerName: "确认色", field: "affirmColor" },
            { headerName: "客户色称", field: "customColorName" },
            { headerName: "对色资料", field: "contrastColor" },
            { headerName: "测试标准", field: "testCriterion" },
            { headerName: "成分", field: "ingredient" },
            { headerName: "po号", field: "customPoCode" },
            { headerName: "投染重量", field: "castDyeWeight" },
            { headerName: "投染码数", field: "castDyeYardage" },
            { headerName: "投染磅数", field: "castDyePound" },

            { headerName: "成品磅数", field: "finishedClothPound" },
            { headerName: "备注", field: "remark" },
            { headerName: "导入人", field: "importPerson" },
            { headerName: "导入日期", field: "importDate" },
            { headerName: "客户品名", field: "customProductName" },
        ];

        /*****************************************************************对色光源****************************************************** */
        //下拉框焦点
        const coloringIlluminantFun = () => {
            coloringIlluminantAll({ colourLight: '' })
        };
        //下拉数据
        let pageDataList = ref([])
        let options = ref<any>(pageDataList.value);
        let loading = ref(false);
        const coloringIlluminantSear = (val: any) => {
            loading.value = true;
            coloringIlluminantAll({ colourLight: val });
            options.value = pageDataList.value;
            loading.value = false;
        };
        function coloringIlluminantAll(val: any) {
            post({
                url: "/pdm/coloringMatch/getFieldValue",
                data: val
            }).then(({ data, code }: any) => {
                if (code === 200) {
                    pageDataList.value = data;
                } else {
                    Message.error({
                        content: "查询失败！",
                        duration: 5000,
                    });
                }
            });
        }
        /****************************************************************客户名称************************************************************** */
        const customNameFun = () => {
            customNameAll({ customName: '' })
        };
        const customNameSear = (val: any) => {
            loading.value = true;
            coloringIlluminantAll({ customName: val });
            options.value = pageDataList.value;
            loading.value = false;
        };
        function customNameAll(val: any) {
            post({
                url: "/aps/custom/getDropValue",
                data: val
            }).then(({ data, code }: any) => {
                if (code === 200) {
                    pageDataList.value = data;
                } else {
                    Message.error({
                        content: "查询失败！",
                        duration: 5000,
                    });
                }
            });
        }
        /*****************************************************************标签格式********************************************************************** */
        const labelFormatCodeFun = () => {
            labelFormatCodeAll({ labelFormat: '' })
        };
        const labelFormatCodeSear = (val: any) => {
            loading.value = true;
            labelFormatCodeAll({ labelFormat: val });
            options.value = pageDataList.value;
            loading.value = false;
        };
        function labelFormatCodeAll(val: any) {
            post({
                url: "/aps/labelFormat/getDropValue",
                data: val
            }).then(({ data, code }: any) => {
                if (code === 200) {
                    pageDataList.value = data;
                } else {
                    Message.error({
                        content: "查询失败！",
                        duration: 5000,
                    });
                }
            });
        };
        /******************************************************************送货地址********************************************************************** */
        function deliveryAddressAll(val: any) {
            post({
                url: "/aps/custom/getCustomDeliveryList",
                data: {
                    customId: val,
                    deletestate: 0
                }
            }).then(({ data, code }: any) => {
                if (code === 200) {
                    form.a.deliveryAddress = data[0].deliveryAddress
                } else {
                    Message.error({
                        content: "查询失败！",
                        duration: 5000,
                    });
                }
            });
        };
        /*******************************************************************回修原因************************************************************************ */
        const repairCauseFun = () => {
            repairCauseAll({ repairCause: '' })
        };
        const repairCauseSear = (val: any) => {
            loading.value = true;
            repairCauseAll({ labelFormat: val });
            options.value = pageDataList.value;
            loading.value = false;
        };
        function repairCauseAll(val: any) {
            post({
                url: "/dwWorkShop/repairCause/selectRepairCause",
                data: val
            }).then(({ data, code }: any) => {
                if (code === 200) {
                    pageDataList.value = data.data;
                } else {
                    Message.error({
                        content: "查询失败！",
                        duration: 5000,
                    });
                }
            });
        };

        return {
            exCustomer,
            pageData,
            form,
            basicData,
            showJu,
            guanxi,
            guanxiData,
            CirclePlus,
            planOrderDetailsAdd,
            planOrderDetails,
            tco,
            columnsOrder,
            defaultColDef,
            gridOptionyB,
            gridReadyeB,
            countBu,
            total,
            colorChe,
            colorCar,
            planorderCastAdd,
            planorderCastGr,
            planorderReaGr,
            tcy,
            InformationEnglishbt,
            xuHaoFun,
            getBu,
            InforRequirement,
            sideaOk,
            yesOrderList,
            gridOptionB,
            gridReadyB,
            orderCustomList,
            baocun,
            sideaNo,
            guanxiCount,
            guanxiForm,
            Search,
            downloadHandler,
            importHandler,
            mobanYn,
            hugeCustomer,
            headerShow,
            testItems,
            coloringIlluminantFun,
            coloringIlluminantSear,
            coloringIlluminantAll,
            pageDataList,
            options,
            loading,
            customNameFun,
            customNameSear,
            customNameAll,
            labelFormatCodeFun,
            labelFormatCodeSear,
            labelFormatCodeAll,
            deliveryAddressAll,
            repairCauseFun,
            repairCauseSear,
            repairCauseAll
        }
    },
    components: {
        Toolbar,
        tagRender,
        cheCk,
        cheCkBumpWhite,
        CheCkdialPrinting,
        checheCkEdgeCK,
        cheCkFirstRate,
        cheCKneedEnterPot,
        cheCkrcInfo,
        cheCkrepeatPack,
        cheCkstainResistance,
        cheCktakeDyeFee,
        cheCkwetRubbing,
        selectGreyCode,
        selectGreyName,
        selectColorCode,
        selectColorName,
        selectAffirmColor,
        selectGreyType,
        selectTrimCharges,
        selectDyeingType,
        selectColorDepth
    },

};
</script>
<style  lang="less">
.my-header {
    background-color: #fff;
}

.pagings {
    margin-top: 10px;
    display: flex;
    justify-content: center;
}

.arco-input-wrapper {
    background-color: #fff !important;
    border: 1px solid #cccccc;
}

.arco-form-item-status-error .arco-input-wrapper:not(.arco-input-disabled),
.arco-form-item-status-error .arco-textarea-wrapper:not(.arco-textarea-disabled) {
    border: 1px solid #f53f3f;
}


/********************************************** */
.stbutencx {
    background-color: #409eff;

    &:hover {
        background-color: #79bbff;
    }
}


.ag-header-cell-resize::after {
    top: 0 !important;
    height: 100% !important;
}

.ag-cell {
    border-right: 1px solid #D9DDDF !important;
}

.stbutenxz {
    background-color: #67c23a;

    &:hover {
        background-color: #b3e19d;
    }
}



/************************************************** */
</style>